package hutech.ksv.view;

import java.io.IOException;
import java.io.Serializable;

import javax.faces.context.FacesContext;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
@Scope("session")
public class HeaderAdminManagedBean implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4684879149735963376L;
	
	@Autowired
	AdminLoginManagedBean adminLoginManagedBean;
	
	public void onLoad() {
		if(adminLoginManagedBean.getThongTinTaiKhoanAdmin() == null) {
			try {
				boolean flag = FacesContext.getCurrentInstance().getExternalContext().isResponseCommitted();
				if(!flag) {
					FacesContext.getCurrentInstance().getExternalContext().redirect("/kenhsinhvien/faces/AdminLogin.xhtml");
				}
			} catch (IOException e) {
				System.out.println(e.getMessage());
			}
		}
	}

}
